package com.yb0os1;

import com.yb0os1.reject.DiscardRejectHandle;
import com.yb0os1.reject.ThrowRejectHandle;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;

public class Main {
    public static void main(String[] args) {
        MyThreadPool myThreadPool = new MyThreadPool(2,4,1, TimeUnit.SECONDS,new ArrayBlockingQueue<>(2),new DiscardRejectHandle());
        for (int i = 0; i < 8; i++) {
            int finalI = i;
            myThreadPool.execute(()->{
               try {
                   Thread.sleep(100);
               } catch (InterruptedException e) {
                   //InterruptedException这个是线程中断异常，
                   // 这个异常一般都是线程在等待或者阻塞中被中断了就会抛出的，
                   // sleep wait等等都是有，除了LockSupport.park 这个会记录中断位 不会抛出这个异常
                   e.printStackTrace();
               }
                System.out.println(Thread.currentThread().getName()+"执行完毕---"+ finalI);
            });
        }
        System.out.println("主线程没有被阻塞");
    }
}
